{include file='public/header'}
<body>
	<div class="sectionY">
		<a href="javascript:history.back()">
			<img src="__PUBLIC__/home/images/a19.png" alt="" class="a1">
		</a>
		<p class="p1">忘记密码</p>
	</div>
	<div class="kong1"></div>
	<div class="res_section1">
		<form action="">
			<div class="f1 clearfix">
				<img src="__PUBLIC__/home/images/register_icon_phone.png" alt="" style="width:21px;left: 21px;">
				<input type="text" name="telephone" class="input1" placeholder="请填写手机号">
			</div>
			<div class="f1 clearfix">
				<img src="__PUBLIC__/home/images/login_icon_pw1.png" alt="">
				<input type="text" name="vcode" class="input1" placeholder="请填写验证码">
				<span class="sr_btn" id="getVcode">获取验证码</span>
			</div>
			<div class="f1 clearfix">
				<img src="__PUBLIC__/home/images/login_icon_pw.png" alt="" style="width:21px;left: 21px;">
				<input type="password" name="password" class="input1" placeholder="请填写密码">
			</div>
			<div class="f1 clearfix">
				<img src="__PUBLIC__/home/images/login_icon_pw.png" alt="" style="width:21px;left: 21px;">
				<input type="password" name="password1" class="input1" placeholder="请确认密码">
			</div>
			<div class="sub">
				<input type="button" id="submit" value="确定">
			</div>
		</form>
	</div>
</body>
<script>
	$(function(){
		$("#getVcode").on('click', function () {
			let telephone = $.trim($("input[name='telephone']").val());
			if (telephone == "") {
				modal.msg("请输入手机号")
				return;
			}
			let o = this;
			$(o).attr("disabled");
			let sec = 60;
			$.post('{:url("getVcode")}', {telephone: telephone, type: 2}, function (res) {
				modal.msg(res.result_info);
				if (res.result_code == 0) {
					let i = setInterval(function () {
						$(o).html(sec + "秒");
						sec--;
						if (sec < 1) {
							clearInterval(i);
							$(o).html("获取验证码");
							$(o).removeAttr("disabled");
						}
					}, 1000);
				} else {
					$(o).removeAttr("disabled");
				}
			});
		})
		$("#submit").on("click", function () {
			let data = {},
					telephone = $.trim($("input[name='telephone']").val()),
					vcode = $.trim($("input[name='vcode']").val()),
					password = $.trim($("input[name='password']").val()),
					password1 = $.trim($("input[name='password1']").val());
			if (telephone == "") {
				modal.msg("手机号不能为空");
				return;
			}
			data.telephone = telephone;
			if (vcode == "") {
				modal.msg("验证码不能为空")
				return
			}
			data.vcode = vcode;
			if (password == "" || !(password.length >= 6 && password.length <= 18)) {
				modal.msg("密码格式不正确，请使用6-18位密码");
				return;
			}
			if (password != password1) {
				modal.msg("两次密码不一致");
				return;
			}
			data.password = password;
			$.post("{:url('forget')}", data, function (res) {
				modal.msg(res.result_info);
				if(res.result_code == 0){
					setTimeout(function () {
						location.href='{:url("login")}';
					},666)
				}
			});
		})
	})
</script>
</html>